//package itbour.onetouchshow.utils.dialog;
//
//import android.annotation.SuppressLint;
//import android.app.Dialog;
//import android.app.DialogFragment;
//import android.content.DialogInterface;
//import android.os.Bundle;
//import android.support.annotation.IntDef;
//import android.support.annotation.Nullable;
//import android.text.InputFilter;
//import android.text.TextUtils;
//import android.view.KeyEvent;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.view.Window;
//import android.view.WindowManager;
//import android.widget.EditText;
//import android.widget.LinearLayout;
//import android.widget.RelativeLayout;
//import android.widget.TextView;
//
//import java.lang.annotation.Retention;
//import java.lang.annotation.RetentionPolicy;
//
//import butterknife.BindView;
//import butterknife.ButterKnife;
//import butterknife.Unbinder;
//import itbour.onetouchshow.R;
//import itbour.onetouchshow.singlecase.InchingDataSingleCase;
//import itbour.onetouchshow.utils.UIUtils;
//
///**
// * 复杂的DialogFragment样式
// * 可以设置弹出框的宽和高
// */
//public  class NewComplexDialogFrag extends DialogFragment {
//    @BindView(R.id.id_ed_ly)
//    RelativeLayout idEdLy;
//    Unbinder unbinder;
//    private boolean mIsKeyCanback = true;
//    private boolean mIsOutCanback = true;
//
//    @BindView(R.id.id_text_title)
//    TextView idTextTitle;
//    @BindView(R.id.id_tv_content)
//    TextView idTvContent;
//
//    @BindView(R.id.id_ed_content)
//    EditText idEdContent;
//
//    @BindView(R.id.id_btn_cancle)
//    TextView idBtnCancle;
//    @BindView(R.id.id_btn_cofirm)
//    TextView idBtnCofirm;
//    @BindView(R.id.id_btn_olny_cofirm)
//    TextView idTvOlnyConfirm;
//
//    @BindView(R.id.id_ly_twobtncontra)
//    LinearLayout idLyTowContext;
//
//    @BindView(R.id.id_ly_onebtncontra)
//    RelativeLayout idLyOneContext;
//
//
//    public final int ONE_BTN = 10;
//    public final int TWO_BTN = 11;
//    public final int ONE_EDIT = 2;
//
//    Builder builder;
//
//
//    @Override
//    public void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        //参考 2.https://github.com/shaohui10086/BottomDialog.git；放其他地方就没有这个效果
//        setCancelable(false);
//        //NO_FRAME就是dialog无边框，0指的是默认系统Theme
//        setStyle(DialogFragment.STYLE_NO_FRAME, R.style.dialog_transparent_style);
//
//    }
//
//
//    /**
//     * isKeyCanback 点击物理返回键可以取消
//     * isOutCanback 点击除了弹出框其他地方可以取消
//     *
//     * @author yjbo  @time 2017/4/22 16:26
//     */
//    @SuppressLint("ValidFragment")
//    public NewComplexDialogFrag(boolean isOutCanback, boolean isKeyCanback) {
//        mIsKeyCanback = isKeyCanback;
//        mIsOutCanback = isOutCanback;
//    }
//
//    @SuppressLint("ValidFragment")
//    public NewComplexDialogFrag() {
//    }
//
//
//    public String getIdEdContent() {
//        String edString = idEdContent.getText().toString();
//        return edString;
//    }
//
//    @Nullable
//    @Override
//    public View onCreateView(LayoutInflater inflater, ViewGroup container,
//                             Bundle savedInstanceState) {
//
//
//
//
////        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
//        getDialog().setCanceledOnTouchOutside(mIsOutCanback);//弹出框外面是否可取消
//        getDialog().setOnKeyListener(new DialogInterface.OnKeyListener() {
//            @Override
//            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
//                if (keyCode == KeyEvent.KEYCODE_BACK) {
////                    getDialog().setCanceledOnTouchOutside(mIsKeyCanback);//键盘点击时是否可以取消--不需要设置了
//                    return !mIsKeyCanback;//return true 不往上传递则关闭不了，默认是可以取消，即return false
//                } else {
//                    return false;
//                }
//            }
//        });
//        // View view = bindLayout(inflater, container);
//        View rootView = inflater.inflate(R.layout.dialog_com, null);
//        unbinder = ButterKnife.bind(this, rootView);
//        bindLayout();
//        return rootView;
//    }
//
//    //protected abstract View bindLayout(LayoutInflater inflater, ViewGroup container);
//
//    protected void bindLayout() {
//        if (null != setBuilder() && idEdContent != null) {
//            String text = setBuilder().mContext;
//            int length = text.length();
//            idEdContent.setText(text);
//            idEdContent.setSelection(length);
//            String context="";
//            if (InchingDataSingleCase.INSTANCE.getLengthControl()!=null){
//                context = "作品名称不超过" + InchingDataSingleCase.INSTANCE.getLengthControl().getProductNameMaxLen() + "字";
//            }
//            idEdContent.setHint(context);
//            if (InchingDataSingleCase.INSTANCE.getLengthControl().getProductNameMaxLen() != 0) {
//                idEdContent.setFilters(new InputFilter[]{new InputFilter.LengthFilter(InchingDataSingleCase.INSTANCE.getLengthControl().getProductNameMaxLen())});
//            }
//        }
//
//
//        if (!TextUtils.isEmpty(setBuilder().mTitle) && idTextTitle != null) {
//            idTextTitle.setText(setBuilder().mTitle);
//        } else {
//            idTextTitle.setVisibility(View.GONE);
//        }
//        if (!TextUtils.isEmpty(setBuilder().mContext) && idTvContent != null) {
//            idTvContent.setText(setBuilder().mContext);
//        }
//        if (!TextUtils.isEmpty(setBuilder().mCancletext) && idBtnCancle != null) {
//            idBtnCancle.setText(setBuilder().mCancletext);
//        }
//        if (!TextUtils.isEmpty(setBuilder().mConfirmText) && idBtnCofirm != null) {
//            idBtnCofirm.setText(setBuilder().mConfirmText);
//        }
//        if (null != setBuilder().mConfirmListener && idBtnCofirm != null) {
//            idBtnCofirm.setOnClickListener(setBuilder().mConfirmListener);
//        }
//        if (null != setBuilder().mCancleListener && idBtnCancle != null) {
//            idBtnCancle.setOnClickListener(setBuilder().mCancleListener);
//        }
//
//        if (null != setBuilder().mConfirmListener && idTvOlnyConfirm != null) {
//            idTvOlnyConfirm.setOnClickListener(setBuilder().mConfirmListener);
//        }
//
//        if (null != setBuilder().mOlnyOneConfirmText && idTvOlnyConfirm != null) {
//            idTvOlnyConfirm.setText(setBuilder().mOlnyOneConfirmText);
//        }
//
////        if (null != setBuilder().mContext && idEdContent != null) {
////            String text = setBuilder().mContext;
////            int length = text.length();
////            idEdContent.setText(text);
////            idEdContent.setSelection(length);
////        }
//
//
//        switch (setBuilder().platform) {
//            case ONE_BTN:
//                idLyTowContext.setVisibility(View.GONE);
//                idLyOneContext.setVisibility(View.VISIBLE);
//                idEdLy.setVisibility(View.GONE);
//                break;
//            case TWO_BTN:
//                idLyTowContext.setVisibility(View.VISIBLE);
//                idLyOneContext.setVisibility(View.GONE);
//                idEdLy.setVisibility(View.GONE);
//                break;
//            case ONE_EDIT:
//                idLyTowContext.setVisibility(View.VISIBLE);
//                idLyOneContext.setVisibility(View.GONE);
//                idEdLy.setVisibility(View.VISIBLE);
//                idTvContent.setVisibility(View.GONE);
//                break;
//            default:
//                idLyTowContext.setVisibility(View.GONE);
//                idLyOneContext.setVisibility(View.VISIBLE);
//                break;
//
//        }
//
//    }
//
//
//    @Override
//    public void onStart() {
//        super.onStart();
//        Window window = getDialog().getWindow();
//        window.setBackgroundDrawableResource(android.R.color.transparent);
//        WindowManager.LayoutParams windowParams = window.getAttributes();
//        //windowParams.dimAmount = 0.0f;
//        // windowParams.y = 100;
//        window.setAttributes(windowParams);
//        Dialog dialog = getDialog();
//        if (dialog != null) {
//            int width = UIUtils.WHD()[0] / 100 * 64;
//            int height = width * 28 / 45;
//            dialog.getWindow().setLayout(width, height);
//        }
//    }
//
//    //protected abstract View bindLayout(LayoutInflater inflater, ViewGroup container);
//
//    //关闭弹出框
//    public void hideDialog() {
//        try {
//            Dialog dialog = getDialog();//没初始化就会出现问题
//            if (dialog != null && dialog.isShowing()) {
//                dialog.dismiss();
//            }
//        } catch (Exception ex) {
//            ex.printStackTrace();
//        }
//    }
//
//    @Override
//    public void onDestroyView() {
//        super.onDestroyView();
//        unbinder.unbind();
//    }
//
//    public class Builder {
//        private String mTitle;
//        private String mContext;
//        private String mCancletext;
//        private String mConfirmText;
//        private String mOlnyOneConfirmText;
//        private View.OnClickListener mCancleListener;
//        private View.OnClickListener mConfirmListener;
//        private int platform;
//
//
//        public Builder setOlnyOneConfirmText(String confirmText) {
//            mOlnyOneConfirmText = confirmText;
//            return this;
//        }
//
//        public Builder setPlatform(@DialogPlatform.Platform int platform) {
//            this.platform = platform;
//            return this;
//        }
//
//        public Builder setTitle(String title) {
//            mTitle = title;
//            return this;
//        }
//
//        public Builder setContext(String context) {
//            mContext = context;
//            return this;
//        }
//
//        public Builder setCancletext(String cancletext) {
//            mCancletext = cancletext;
//            return this;
//        }
//
//        public Builder setConfirmText(String confirmText) {
//            mConfirmText = confirmText;
//            return this;
//        }
//
//        public Builder setCancleListener(View.OnClickListener onClickListener) {
//            mCancleListener = onClickListener;
//            return this;
//        }
//
//        public Builder setConfirmListener(View.OnClickListener onClickListener) {
//            mConfirmListener = onClickListener;
//            return this;
//        }
//    }
//
//    public static class DialogPlatform {
//        @IntDef({ONE_BTN, TWO_BTN,
//                ONE_EDIT})
//        @Retention(RetentionPolicy.SOURCE)
//        public @interface Platform {
//        }
//
//        public static final int ONE_BTN = 10;
//        public static final int TWO_BTN = 11;
//        public static final int ONE_EDIT = 2;
//    }
//
//
//}